using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DogDetector : MonoBehaviour
{
    private AudioSource audioSource;
    private AudioClip audioDog;

    void Awake()
    {
        this.audioSource = GetComponent<AudioSource>();
        audioDog = Resources.Load<AudioClip>("Audios/NPC/Dog");
    }

    void OnTriggerEnter2D(Collider2D collision)
    {
        this.audioSource.clip = this.audioDog;
        this.audioSource.Play();
    }

    void OnTriggerExit2D(Collider2D collision)
    {
        this.StopAudio();
    }

    public void StopAudio()
    {
        this.audioSource.Stop();
    }
}
